<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>通行证</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>

    <style>
        .con {
            border: 1px solid green;
            position: absolute;
            top: 50%;
            left: 50%;
            margin: -225px 0 0 -400px;
        }
    </style>

</head>
<body>
<div id="container" style=" width: 800px;height: 450px;">
    <table border="0px" cellspacing="10" class="con">
        <tr>
            <th>通行证</th>
        </tr>
        <tr>
            <td>
                <input type="text" v-model="username">
            </td>
        </tr>
        <tr>
            <td>
                <input type="password" v-model="password">
            </td>
        </tr>
        <tr>
            <!--            <td>-->
            <!--                <input type="button" value="注册" @click.prevent="register1()">-->
            <!--            </td>-->
            <td>
                <input type="button" value="登录" @click.prevent="signIn()">
            </td>
        </tr>
    </table>

</div>
</body>

<script>
    new Vue({
        el: "#container",
        data: {
            username: 'admin',
            password: '123'
        },
        methods: {
            register1: function () {
                axios.post("/web_stu_info/account/register.action", {
                    "username": this.username,
                    "password": this.password
                })
                    .then(function (response) {

                    }, function (error) {
                        confirm(error);
                    });
            },
            signIn: function () {
                axios.get("/web_stu_info/account/signIn.action", {
                    params: {
                        "username": this.username,
                        "password": this.password
                    }
                })
                    .then(function (response) {
                        console.log(response.data);
                        var data = response.data;
                        if (data.flag > 0) {
                            if (confirm(data.message))
                                self.location = data.target;
                        } else
                            confirm(data.message);
                    }, function (error) {
                        confirm(error);
                    });

            }
        },
    });
</script>

</html>